<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Espacio extends CI_Model{
	
	private $table = 'espacio';
	
	function __construct(){
		parent::__construct();
	}
	function all(){
		return $this->db->get($this->table)->result();		
	}
	function id($id){
		$this->db->where('id', $id);
		$query = $this->db->get($this->table);
		if($query->num_rows() > 0)	
			return $query->row();
		else return FALSE; 
	}
	function insert($espacio){
		$this->db->insert($this->table, $espacio);
		if($this->db->affected_rows())
			return $this->db->insert_id();
		else return 0;
	}
	function update($espacio, $id){
		$this->db->where('id',$id);
		$this->db->update($this->table, $espacio);
		return $this->db->affected_rows();
	}
	function delete($id){
		$this->db->delete($this->table, array('id' => $id));
		return $this->db->affected_rows();
	}
}
